package cn.kshost.zqyg.manager.controller;

import cn.kshost.zqyg.manager.service.FileUploaderService;
import cn.kshost.zqyg.model.vo.common.Result;
import cn.kshost.zqyg.model.vo.common.ResultCodeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/admin/uploadFile")
public class FileUploadController {
    @Autowired
    FileUploaderService fileUploaderService;

    @PostMapping("/avatar")
    public Result<String> uploadAvatar(@RequestParam("file") MultipartFile file) {
        String url = fileUploaderService.upLoadAvatar(file);
        return Result.build(url, ResultCodeEnum.SUCCESS);
    }

    @PostMapping("/logo")
    public Result<String> uploadLogo(@RequestParam("file") MultipartFile file) {
        String url = fileUploaderService.upLoadLogo(file);
        return Result.build(url, ResultCodeEnum.SUCCESS);
    }


}